package caiwei.android_study_sample.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.SimpleExpandableListAdapter;
import android.widget.Toast;

public class Android07UIBaseSampleExpandablelistview extends
		ExpandableListActivity
{

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		List<HashMap<String, String>> groupData = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> _HashMap1 = new HashMap<String, String>();
		_HashMap1.put("Name", "beijing");
		groupData.add(_HashMap1);
		_HashMap1 = new HashMap<String, String>();
		_HashMap1.put("Name", "shanghai");
		groupData.add(_HashMap1);
		_HashMap1 = new HashMap<String, String>();
		_HashMap1.put("Name", "tarena");
		groupData.add(_HashMap1);

		List<List<HashMap<String, String>>> childData = new ArrayList<List<HashMap<String, String>>>();
		List<HashMap<String, String>> _ChildItem = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> _HashMap2 = new HashMap<String, String>();
		_HashMap2.put("tel", "01");		
		_HashMap2.put("address", "aaa");
		_ChildItem.add(_HashMap2);
		childData.add(_ChildItem);
		_ChildItem = new ArrayList<HashMap<String, String>>();
		_HashMap2 = new HashMap<String, String>();
		_HashMap2.put("tel", "02");		
		_HashMap2.put("address", "bbbb");
		_ChildItem.add(_HashMap2);
		childData.add(_ChildItem);
		_ChildItem = new ArrayList<HashMap<String, String>>();
		_HashMap2 = new HashMap<String, String>();
		_HashMap2.put("tel", "03");		
		_HashMap2.put("address", "cccc");
		_ChildItem.add(_HashMap2);
		childData.add(_ChildItem);

		ExpandableListAdapter _ExpandableListAdapter = new SimpleExpandableListAdapter(
				this, groupData,
				android.R.layout.simple_expandable_list_item_1,
				android.R.layout.simple_expandable_list_item_1, new String[] {
						"Name", "address" }, new int[] { android.R.id.text1,
						android.R.id.text2 }, childData,
				android.R.layout.simple_list_item_2, new String[] { "tel",
						"address" }, new int[] { android.R.id.text1,
						android.R.id.text2 });

		setListAdapter(_ExpandableListAdapter);
	}

	@Override
	public boolean onChildClick(ExpandableListView parent, View v,
			int groupPosition, int childPosition, long id)
	{
		// TODO Auto-generated method stub
		return super.onChildClick(parent, v, groupPosition, childPosition, id);
	}

	@Override
	public void onGroupCollapse(int groupPosition)
	{
		// TODO Auto-generated method stub
		super.onGroupCollapse(groupPosition);
	}

	@Override
	public void onGroupExpand(int groupPosition)
	{
		super.onGroupExpand(groupPosition);
		Toast.makeText(this,""+groupPosition, 1).show();
	}

}
